package com.jd.jr.util;

import com.ibatis.sqlmap.client.extensions.ParameterSetter;
import com.ibatis.sqlmap.client.extensions.ResultGetter;
import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;
import com.jd.jr.model.ExtendsVo;

import java.sql.SQLException;


// 继承自BaseTypeHandler<Object> 使用Object是为了让JsonUtil可以处理任意类型
public class JsonTypeHandler2 implements TypeHandlerCallback {
    @Override
    public void setParameter(ParameterSetter setter, Object parameter) throws SQLException {
        setter.setString(JsonUtil.stringify(parameter));
    }

    @Override
    public ExtendsVo getResult(ResultGetter getter) throws SQLException {
        return JsonUtil.parse(getter.getString(), ExtendsVo.class);
    }

    @Override
    public Object valueOf(String s) {
        return null;
    }
   
   
}